from hitprobability import *
class Magician:#法师的信息
    def magician_role(self,name,hp,attack,probability_judge):
        self.name=name                             #法师的姓名
        self.hp=hp                                 #法师的生命值
        self.attack=attack                         #法师的攻击
        self.probability_judge=probability_judge   #法师的命中概率
    def magician_attack(self, attack_obj):
        """
        法师的攻击方法
        :param attack_obj: 攻击的对象
        :return:
        """
        if probability_judge(self.probability_judge):
            attack_obj.hp -= self.attack-attack_obj.defense*10
        else:
            print("%s法师，伯乐看了都说好马，导致法术丢失了!" % self.name)
magician=Magician()#法师(创建对象)
magician.magician_role("hxb",100,30,0.2)
class Soldier:#战士的信息
    def soldier_role(self,name,hp,step,distance,defense):
        self.name=name                      #战士的姓名
        self.hp=hp                          #战士的生命值
        self.step=step                      #战士每个回合前进的格子
        self.distance=distance              #战士与法师的距离
        self.defense=defense
    def soldier_attack(self, attack_obj,attack_mod):
        """
        战士的攻击方法
        :param attack_obj: 攻击的对象
        :return:
        """
        if   attack_mod==1:                       #前进
            soldier.distance-=2
        elif attack_mod==2:                        #回复
            soldier.hp+=32
        else:  #护甲系统
            soldier.defense+=1
            magician.attack=magician.attack-soldier.defense*10
        if soldier.distance<=0:
            magician.hp=0
soldier=Soldier()#战士(创建对象)
soldier.soldier_role("xzy",200,2,12,0)
def info(self):                         #战况显示
        print("战士%s， 剩余血量%i, 距离法师距离%i" % (self.name, self.hp, self.distance))



